define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            $.fn.bootstrapTable.locales[Table.defaults.locale]['formatSearch'] = function(){return "请求类型名称-搜索";};
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'params_type/index' + location.search,
                    add_url: 'params_type/add',
                    edit_url: 'params_type/edit',
                    del_url: 'params_type/del',
                    multi_url: 'params_type/multi',
                    import_url: 'params_type/import',
                    table: 'params_type',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'), operate: 'LIKE'},
                        // {field: 'type', title: __('Type')},
                        {
                            field: 'status',
                            title: '状态',
                            align: 'center',
                            table: table,
                            formatter: Table.api.formatter.toggle,
                            sortable: true,
                            searchList: {1: __('有效'),2: __('无效') },
                            cellStyle: Controller.api.formatter.css,
                        },

                        // {field: 'status', title: __('Status')},


                        {field: 'create_time', title: __('Create_time'),formatter: Table.api.formatter.datetime, operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'update_time', title: __('Update_time'),formatter: Table.api.formatter.datetime, operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            formatter: {
                css:function(){
                    return{
                        css:{
                            "min-width":"120px !important",
                            // "overflow":"hidden",
                            // "white-space":"nowrap",
                            // "text-overflow":"ellipsis",
                            // "display":"block",
                        }
                    };
                },

            }
        }
    };
    return Controller;
});